package HuaWei;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * @author fly
 * @create 2021--04--19--14:23
 */
public class wangyi2 {
    public static void main(String[] args) {
        long[][] logs=new long[][]{
                {1610000000000L,1620000000000L},
                {1610000000000L,1610000000100L},
                {1615000000000L,1620000000100L},
                {1610000000000L,16160000000100L}
        };
        long[] tss=new long[]{
                1610000000000L,  1615000000000L
        };
        int[][] ans = search_log(logs, tss);
        for(int[] a:ans){
            for(int x:a){
                System.out.print(x+" ");
            }
            System.out.println();
        }
    }
    public static int[][] search_log(long[][] logs,long[] tss){
        int[][] ans=new int[tss.length][logs.length];
        List<pair> list=new ArrayList<>();
        for(int i=0;i<logs.length;i++){
            list.add(new pair(new pair(logs[i][0],logs[i][1]),i));
        }
        Collections.sort(list, new Comparator<pair>() {
            @Override
            public int compare(pair o1, pair o2) {
                if(o1.son.first>o2.son.first)return 1;
                else return -1;
            }
        });
        for(int i=0;i<tss.length;i++){
            int idx=0;
            for(int j=0;j< list.size();j++){
                if(tss[i]<list.get(j).son.first)break;
                if(tss[i]<=list.get(j).son.second)ans[i][idx++]=list.get(j).id;
            }
        }
        return ans;
    }
}
class pair{
    long first;
    long second;
    pair son;
    int id;
    public pair(long first,long second){
        this.first=first;
        this.second=second;
    }
    public pair(pair son,int id){
        this.son=son;
        this.id=id;
    }
}
